package com.sparrow.gate.redis.queue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;

@Component
public class RedisMsgSender
{
    @Autowired
    private StringRedisTemplate stringTemplate;

    @Autowired
    @Qualifier("redisTemplate")
    private RedisTemplate redisTemplate;

    public void sendMsg(String channel, String message)
    {
        //ValueOperations<String,Object> operation = redisTemplate.opsForValue();
        //operation.set("test","test_value");
        ValueOperations<String, String> operation = stringTemplate.opsForValue();
        operation.set("test","test_value");


        stringTemplate.convertAndSend(channel, message);

//        RedisSerializer<String> stringSerializer = new StringRedisSerializer();
//        template.setKeySerializer(stringSerializer );
//        template.setValueSerializer(stringSerializer );
//        template.setHashKeySerializer(stringSerializer );
//        template.setHashValueSerializer(stringSerializer );
//        template.convertAndSend(channel, message);
    }
}
